home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-16 | 2.1 KB | 95 lines | [TEXT/EDIT] |
- #!perl
- # This script takes the plain miniperlmain.c and writes out perlmain.c
- # which includes all the extensions.
- # The command line arguments name extensions to be used.
- # E.g.: miniperl writemain SDBM_File POSIX > perlmain.c
- #
-
- if ($ARGV[0] eq "-runperl") {
- $runperl = shift @ARGV;
- }
-
- foreach (@ARGV) {
- s/\.o$//; s/\.o\.PPC$//; s/\.o\.68K$//;
- s/ext:(.*):[^:]*/$1/ && next;
- s/.*:(.*)/$1/;
- }
-
- open(MAIN, "miniperlmain.c") || die "Couldn't open miniperlmain.c: $!";
-
- while (<MAIN>) {
- s/perl_destruct/perl_destruct_level = 2;\n\n perl_destruct/ if $runperl;
- s/^main\(/run_perl\(/ if $runperl;
- last if /Do not delete this line--writemain depends on it/;
- print;
- }
-
- print <<EOP;
-
- static void
- xs_init()
- {
- dXSUB_SYS;
- EOP
-
- if ($#ARGV > -1) {
- print " char *file = __FILE__;\n";
- $ai = "";
-
- foreach $ext (@ARGV) {
- ($mname = $ext) =~ s!/!::!g;
- ($cname = $mname) =~ s!:!_!g;
-
- print " { extern void boot_${cname} _((CV* cv));\n";
-
- if ($ext eq "DynaLoader") {
- # Must NOT install 'DynaLoader::boot_DynaLoader' as 'bootstrap'!
- # boot_DynaLoader is called directly in DynaLoader.pm
- print " newXS(\"${mname}::boot_${ext}\", boot_${cname}, file);\n";
- } else {
- print " newXS(\"${mname}::bootstrap\", boot_${cname}, file);\n";
- }
-
- if (opendir(AUTOINIT, ":ext:$ext:")) {
- while ($auto = readdir(AUTOINIT)) {
- next unless ($auto =~ /^AutoInit\./i);
- open(AI, ":ext:$ext:$auto");
- if ($auto =~ /\.c$/) {
- print " /* autoinit code from $aifile follows: */\n";
- print " {\n";
- while (<AI>) {
- print;
- }
- print " }\n";
- } elsif ($auto =~ /\.pl$/) {
- while (<AI>) {
- chop;
- $ai .= $_ . " ";
- }
- }
- }
- }
- print " }\n";
- }
- if ($ai ne "") {
- print <<END_AUTOBOOT;
- if (!preambleav)
- preambleav = newAV();
- av_push(preambleav, newSVpv("BEGIN { $ai }",0));
- END_AUTOBOOT
- }
- print " av_push(GvAVn(incgv), newSVpv(\"Dev:Pseudo:\", 0));\n" if ($runperl);
- }
- print "}\n";
-
- if ($runperl) {
- print <<END_EXIT;
-
- #undef exit
-
- void (exit)(int status)
- {
- my_exit(status);
- }
- END_EXIT
- }